<script setup>
import { onMounted, ref, onBeforeUnmount } from "vue"
import {household,flow,important,reset_params} from "@/js/request_params"
import {select_imp_idnum_info} from '@/js/resident_request_func';
import {get_json_object} from "@/js/area"
import { housetype,relation,gender, bloodMap, nation, education, marry, military, persontype, undercontrol } from "@/js/base_info_map";
import zhCn from "element-plus/es/locale/lang/zh-cn"
import { Object } from "core-js";
import { delete_imp_info } from "@/api/impPop";
import { userStore } from "@/store/user";
import { ElMessage } from "element-plus";
// 后续扩展请复制该文件
//family_establishment_服务
let json_object = ref([]);
const store = userStore();
const locale = ref(zhCn);
const service_form = ref();

const direction = ref('btt');
const drawer = ref(false);
const disabledDate = (time) => {
  return time.getTime() > Date.now();
}
const handle_close = () => {
  drawer.value = false;
}

const initImportant = ()=>{
  important.value.pid = store.get_use_info.pid;
  important.value.operatorId = store.get_use_info.id;
  important.value.changetype = "重点人口信息注销";
  important.value.changereson = "重点人口信息注销";
  important.value.pname = store.get_use_info.pname;
  important.value.popTypeId = 2;
}

const resteImportant = ()=>{

  important.value.name = '';
  important.value.idnum = '';
  important.value.birthday = '';
  important.value.genderId = '';
  important.value.nationId = '';
  important.value.bloodId = '';
  important.value.eduId = '';
  important.value.marryId = '';
  important.value.disabilityId = '';
  important.value.militaryId = '';
  important.value.address = '';
  important.value.persontypeId = '';
  important.value.undercontrolId = '';
  important.value.personnum = '';
// initImportant();
}


onMounted(async () => {
  let response =  await get_json_object()
  json_object.value.push(response);
  initImportant();
})

onBeforeUnmount(()=>{
  reset_params(important.value)
})

const deleteImpInfo = ()=>{
  delete_imp_info(important.value).then((res)=>{
    ElMessage.success(res.msg);
    resteImportant();
  })

  setTimeout(()=>{
    location.reload()
  },500)
}

</script>
<template>

  <div class="w-[100%] h-[100%] flex justify-center">
    <div class="card w-[100%] h-[100%] flex justify-center">
      <spa class="span"></spa>
      <span class="span"></span>
      <span class="span"></span>
      <spa class="span"></spa>
      <div class="shell shadow-xl" style="width:90%;height:90%">
        <svg class="check" xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512">

          <path
              d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z">
          </path>
        </svg>
        <p class="tracking-[10px] text-[20px] font-[800] text-black">重点人口信息注销</p>
        <el-form class="grid  grid-cols-3 gap-x-14 -gap-y-1  relative justify-items-center items-center"
                 :model="important" ref="service_form" :rules="rules">
          <el-form-item label="姓名:">
            <el-input v-model="important.name" placeholder="请填写内容"></el-input>
          </el-form-item>
          <el-form-item label="性别:">
            <el-select v-model="important.genderId" placeholder="请选择">
              <el-option v-for="index in Object.keys(gender).length" :key="index" :label="gender[index]"
                         :value="index"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="人员类别:">
            <el-select v-model="important.persontypeId" placeholder="请选择">
              <el-option v-for="index in Object.keys(persontype).length" :key="index" :label="persontype[index]"
                         :value="index"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="出生日期:">
            <el-config-provider :locale="locale">
              <el-date-picker style="width:180px" v-model="important.birthday" format="YYYY-MM-DD"
                              value-format="YYYY-MM-DD" type="date" placeholder="请选择" :disabled-date="disabledDate"
                              :size="'default'" />
            </el-config-provider>
          </el-form-item>
          <el-form-item label="身份证号:">
            <el-input v-model="important.idnum" placeholder="请填写内容" @change="select_imp_idnum_info"></el-input>
          </el-form-item>
          <el-form-item label="婚姻状况:">
            <el-select v-model="important.marryId" placeholder="请选择">
              <el-option v-for="index in Object.keys(marry).length" :key="index" :label="marry[index]"
                         :value="index"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="在控状态:">
            <el-select v-model="important.undercontrolId" placeholder="请选择">
              <el-option v-for="index in Object.keys(undercontrol).length" :key="index" :label="undercontrol[index]"
                         :value="index"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="人员编号:">
            <el-input v-model="important.personnum" placeholder="请填写内容"></el-input>
          </el-form-item>
          <el-form-item label="户籍地址:">
            <el-input v-model="important.address" placeholder="请填写内容"></el-input>
          </el-form-item>
          <el-form-item label="血型:">
            <el-select v-model="important.bloodId" placeholder="请选择">
              <el-option v-for="index in Object.keys(bloodMap).length" :key="index" :label="bloodMap[index]"
                         :value="index"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="民族:">
            <el-select v-model="important.nationId" placeholder="请选择">
              <el-option v-for="index in Object.keys(nation).length" :key="index" :label="nation[index]"
                         :value="index"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="文化程度:">
            <el-select v-model="important.eduId" placeholder="请选择">
              <el-option v-for="index in Object.keys(education).length" :key="index" :label="education[index]"
                         :value="index"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="兵役状况:">
            <el-select v-model="important.militaryId" placeholder="请选择">
              <el-option v-for="index in Object.keys(military).length" :key="index" :label="military[index]"
                         :value="index"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="业务类别:">
            <el-input placeholder="重点人口信息注销" disabled></el-input>
          </el-form-item>
          <el-form-item label="派出所:">
            <el-input v-model="important.pname" placeholder="请填写" disabled></el-input>
          </el-form-item>
          <el-form-item class="col-start-1 col-span-3" label="注销原因:" label.width="100px">
            <el-input v-model="important.reason" placeholder="请填写" style="width:950px"></el-input>
          </el-form-item>
        </el-form>

        <hr>
        <div class="relative -top-1  flex justify-around items-center">
          <button class="card_button" @click="deleteImpInfo">
            注销
            <svg class="arrow" xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512">
              <path
                  d="M470.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 256 265.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160zm-352 160l160-160c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L210.7 256 73.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0z">
              </path>
            </svg>
          </button>
          <button class="card_button" @click="select_imp_idnum_info(important.idnum)">
            查询信息
            <svg class="arrow" xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512">
              <path
                  d="M470.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 256 265.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160zm-352 160l160-160c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L210.7 256 73.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0z">
              </path>
            </svg>
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
@import url(../css/form_card.css);
.el-form {
  height: 70%;
}
:deep(.el-input__wrapper) {
  transition: all 500ms;
}
.el-input :deep(.el-input__wrapper.is-focus){
  --tw-ring-color: rgb(216 180 254);
  --tw-ring-offset-color: #84f2fc;
  box-shadow: var(--tw-ring-inset) 0 0 3px calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);

}
.el-input :deep(.el-input__wrapper) {
  transition: all 500ms;
}
.el-input,
.el-select {

  width:180px;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}
:deep(.el-form-item__label) {
  text-shadow: 1px 2px 2px rgba(165, 165, 165, 0.8);
}
.el-form-item:nth-child(1) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 12px;
}
.el-form-item:nth-child(2) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 12px;
}
.el-form-item:nth-child(3) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing:2px;
}
.el-form-item:nth-child(4) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(5) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(6) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(7) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(8) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(9) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(10) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 12px;
}
.el-form-item:nth-child(11) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 12px;
}
.el-form-item:nth-child(12) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(13) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(14) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(15) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 6px;
}
.el-form-item:nth-child(16) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(17) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 2px;
}
.el-form-item:nth-child(18) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 1px;
}
.el-form-item:nth-child(19) :deep(.el-form-item__label) {
  position: relative;
  right: 0;
  letter-spacing: 1px;
}
</style>
